package com.shujia.wyh.day10;

import java.util.ArrayList;
import java.util.Random;

/*
    获取10个1-20之间的随机数，要求不能重复
 */
public class RandomTest4 {
    public static void main(String[] args) {
        ArrayList<Integer> list = new ArrayList<>();
        Random random = new Random();

        int count = 0;
        while (count<10){
            int number = random.nextInt(20)+1;
            if(!list.contains(number)){
                list.add(number);
                count++;
            }
        }

        System.out.println(list);
    }
}
